n=int(input())
k = 0
if 999 < n < 10000:
    for i in range(2,n//2):
        if n % i == 0 :
            k = 1
        if k == 0:
            print(n)
else:
    print(0)
            
